//
//  TaskLogTableViewCell.m
//  OAProject
//
//  Created by yhj on 2017/3/8.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "TaskLogTableViewCell.h"

@interface TaskLogTableViewCell ()

@property(nonatomic,strong)ZZCircleProgress *circleProgress;

// 任务操作
@property(nonatomic,strong)UILabel *taskNameLabel;

// 任务日志
@property(nonatomic,strong)UILabel *taskLogLabel;

// 任务记录时间
@property(nonatomic,strong)UILabel *taskTimeLabel;


@end

@implementation TaskLogTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.taskTimeLabel.font=Font_Number(14);

        self.taskNameLabel.font=Font_Number(16);

        self.taskLogLabel.font=Font_Number(16);

        self.backgroundColor=WhiteColor;
    }
    return self;
}

-(ZZCircleProgress *)circleProgress
{
    if (!_circleProgress) {
        _circleProgress=[ZZCircleProgress new];
        _circleProgress.progress=.4;
        _circleProgress.showPoint=NO;
        _circleProgress.animationModel=CircleIncreaseSameTime;
        ViewBorderRadius(_circleProgress,kmargin*2,1,ClearColor);
        [self.contentView addSubview:_circleProgress];
        [_circleProgress mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(kmargin*5,kmargin*5));
            make.centerY.mas_equalTo(self);
            make.left.mas_equalTo(kmargin*2);
        }];
    }
    return _circleProgress;
}


// taskNameLabel
- (UILabel *)taskNameLabel
{
    if (!_taskNameLabel) {
        _taskNameLabel=[self getLabelWithText:@"李四增加了任务下载时间 " font:Font_Number(16) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_taskNameLabel];
        [_taskNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.circleProgress.mas_top);
            make.left.mas_equalTo(self.circleProgress.mas_right).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _taskNameLabel;
}

// taskLogLabel
- (UILabel *)taskLogLabel
{
    if (!_taskLogLabel) {
        _taskLogLabel=[self getLabelWithText:@"任务日志记录" font:Font_Number(14) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_taskLogLabel];
        [_taskLogLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.taskNameLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(self.taskNameLabel.mas_left);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _taskLogLabel;
}


// taskTimeLabel
- (UILabel *)taskTimeLabel
{
    if (!_taskTimeLabel) {
        _taskTimeLabel=[self getLabelWithText:@"1天前" font:Font_Number(14) textColor:LightGreyColor textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_taskTimeLabel];
        [_taskTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.taskLogLabel.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _taskTimeLabel;
}

-(void)setModel:(TaskLogListModel *)model
{
    self.circleProgress.progress=model.tempo/100;
    self.taskNameLabel.text=[NSString stringWithFormat:@"%@%@",model.user_name,model.action_show];
    self.taskTimeLabel.text=model.in_time;
    self.taskLogLabel.text=model.memo;
}

@end
